//
//  LevelSelectViewController.m
//  TigerClef
//
//  Created by Jamie Chong on 6/29/13.
//  Copyright (c) 2013 Christopher Laguna. All rights reserved.
//

#import "LevelSelectViewController.h"
#import "AppDelegate.h"
#import "ViewController.h"

int levelsBeat;

@interface LevelSelectViewController ()

@end

@implementation LevelSelectViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor cyanColor];
    
    UITextField *textTitle = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 200, 22)];
    textTitle.text = @"Levels";
    textTitle.font = [UIFont boldSystemFontOfSize:19];
    textTitle.textColor = [UIColor whiteColor];
    textTitle.textAlignment = NSTextAlignmentCenter;
    self.navigationItem.titleView = textTitle;
    
    UIButton *levelOneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    levelOneButton.frame = CGRectMake((self.view.frame.size.width/2) - 70, self.view.frame.size.height - 400, 130, 30);
    [levelOneButton setTitle:@"1) Treble Clef" forState:(UIControlState)UIControlStateNormal];
    [levelOneButton addTarget:self action:@selector(levelOneClicked:) forControlEvents:(UIControlEvents)UIControlEventTouchUpInside];
    [self.view addSubview:levelOneButton];
    
    UIButton *levelTwoButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    levelTwoButton.frame = CGRectMake((self.view.frame.size.width/2) - 70, self.view.frame.size.height - 350, 130, 30);
    [levelTwoButton setTitle:@"2) Bass Clef" forState:(UIControlState)UIControlStateNormal];
    [levelTwoButton addTarget:self action:@selector(levelTwoClicked:) forControlEvents:(UIControlEvents)UIControlEventTouchUpInside];
    if (levelsBeat < 1)
        [levelTwoButton setEnabled:NO];
    [self.view addSubview:levelTwoButton];
    
    UIButton *levelThreeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    levelThreeButton.frame = CGRectMake((self.view.frame.size.width/2) - 70, self.view.frame.size.height - 300, 130, 30);
    [levelThreeButton setTitle:@"3) Alto Clef" forState:(UIControlState)UIControlStateNormal];
    [levelThreeButton addTarget:self action:@selector(levelThreeClicked:) forControlEvents:(UIControlEvents)UIControlEventTouchUpInside];
    if (levelsBeat < 2)
        [levelThreeButton setEnabled:NO];
    [self.view addSubview:levelThreeButton];
    
    UIButton *levelFourButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    levelFourButton.frame = CGRectMake((self.view.frame.size.width/2) - 70, self.view.frame.size.height - 250, 130, 30);
    [levelFourButton setTitle:@"4) Tenor Clef" forState:(UIControlState)UIControlStateNormal];
    [levelFourButton addTarget:self action:@selector(levelFourClicked:) forControlEvents:(UIControlEvents)UIControlEventTouchUpInside];
    if (levelsBeat < 3)
        [levelFourButton setEnabled:NO];
    [self.view addSubview:levelFourButton];
    
    UIButton *levelFiveButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    levelFiveButton.frame = CGRectMake((self.view.frame.size.width/2) - 70, self.view.frame.size.height - 200, 130, 30);
    [levelFiveButton setTitle:@"5) Medieval Clef" forState:(UIControlState)UIControlStateNormal];
    [levelFiveButton addTarget:self action:@selector(levelFiveClicked:) forControlEvents:(UIControlEvents)UIControlEventTouchUpInside];
    if (levelsBeat < 4)
        [levelFiveButton setEnabled:NO];
    [self.view addSubview:levelFiveButton];

}

- (void)levelOneClicked : (id) sender {
    AppDelegate *appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
    [appDelegate.navController pushViewController: [[ViewController alloc] initWithLevel:1] animated:YES];
    
}

- (void)levelTwoClicked : (id) sender{
    
    AppDelegate *appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
    [appDelegate.navController pushViewController: [[ViewController alloc] initWithLevel:2] animated:YES];
    
}

- (void)levelThreeClicked : (id) sender{
    AppDelegate *appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
    [appDelegate.navController pushViewController: [[ViewController alloc] initWithLevel:3] animated:YES];
}

- (void)levelFourClicked : (id) sender{
    AppDelegate *appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
    [appDelegate.navController pushViewController: [[ViewController alloc] initWithLevel:4] animated:YES];
}

- (void)levelFiveClicked : (id) sender{
    AppDelegate *appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
    [appDelegate.navController pushViewController: [[ViewController alloc] initWithLevel:5] animated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
